#ifndef __AS_FT_IO__H__
#define __AS_FT_IO__H__

#include "ASFTData.h"

#define ASFT_DIR "@ymft"

#define __ASFT_FILE_ACCOUNT "@ac"
#define __ASFT_FILE_PAYTYPE "@pt"
#define __ASFT_FILE_INCOMTYPE "@it"
#define __ASFT_FILE_RECORD "@rc"
#define __ASFT_FILE_RECORD_TMP "@rc_tmp"
#define __ASFT_FILE_SETTING "@si"

/*default file types,if you change the method gen default data,this defines should be sync.*/
#define AS_FT_DEFAULT_INCOME_TYPES 14
#define AS_FT_DEFAULT_PAY_TOP_TYPES 8
#define AS_FT_DEFAULT_PAY_SUB1_TYPES 10
#define AS_FT_DEFAULT_PAY_SUB2_TYPES 16
#define AS_FT_DEFAULT_PAY_SUB3_TYPES 15
#define AS_FT_DEFAULT_PAY_SUB4_TYPES 10
#define AS_FT_DEFAULT_PAY_SUB5_TYPES 6
#define AS_FT_DEFAULT_PAY_SUB6_TYPES 14
#define AS_FT_DEFAULT_PAY_SUB7_TYPES 9
#define AS_FT_DEFAULT_PAY_SUB8_TYPES 5
#define AS_FT_DEFAULT_MEMBER_TYPES 2

typedef enum
{
    /*internal files*/
    ASFT_FILE_MEMBER,
    ASFT_FILE_PAYTYPE,
    ASFT_FILE_INCOMETYPE,
    ASFT_FILE_SETTING,

    /*custom files*/
    ASFT_FILE_RECORD,
    ASFT_FILE_RECORD_TMP,


    ASFT_FILE_MAX

} as_ft_file;


ASCHAR* as_ft_get_tmp_astr(void);
ASWCHAR* as_ft_get_tmp_wstr(void);

ASCHAR* as_ft_get_dir(void);
void as_ft_gen_dir(void);
void as_ft_gen_default_data(void);
void as_ft_reset_default(void);

/*file operation functions*/
ASSTR as_ft_get_file_path(as_ft_file ft, ASINT param);
ASINT as_ft_file_open(as_ft_file ft, ASINT param, as_file_op_mode mode);
void as_ft_file_close(ASINT fh);
ASBOOL as_ft_check_if_exist(as_ft_file ft, ASINT param);

as_ret as_ft_file_add_data(ASINT fh, ASINT max_data_cnts, ASINT data_len, void* data_p);
as_ret as_ft_file_cover_data(ASINT fh, ASINT max_data_cnts, ASINT data_len, void* data_p, ASINT idx);
as_ret as_ft_file_delete_data(ASINT fh, ASINT max_data_cnts, ASINT idx);
//as_ret as_ft_file_move_data(ASINT fh,ASINT max_data_cnts,ASINT each_data_len,ASINT from_idx,ASINT to_idx);
ASINT as_ft_file_get_data_cnts(ASINT fh);
as_ret as_ft_file_get_data(ASINT fh, ASINT max_data_cnts, void* out_data_p, ASINT data_len, ASINT idx);
as_ret as_ft_file_resize(ASINT fh, ASINT new_size);

ASINT as_ft_file_get_param_by_date(as_time time);
as_ret as_ft_file_add_new_record(as_ft_main_data_v2* data_p);


ASBOOL as_ft_get_if_first_used(void);
void as_ft_set_if_first_used(ASBOOL if_first_used);

ASINT as_ft_file_get_param_from_rec_file_name(ASSTR file_name);





#endif//__AS_FT_IO__H__